home *** CD-ROM | disk | FTP | other *** search
- unit OldDragU;
-
- interface
-
- uses
- WinProcs, WinTypes, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- ExtCtrls, StdCtrls;
-
- type
- TForm1 = class(TForm)
- lstFiles: TListBox;
- procedure FormCreate(Sender: TObject);
- procedure FormDestroy(Sender: TObject);
- private
- { Private declarations }
- public
- procedure WMDropFiles(var Msg: TWMDropFiles);
- message wm_DropFiles;
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- uses
- ShellAPI;
-
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- DragAcceptFiles(Handle, True);
- end;
-
- procedure TForm1.FormDestroy(Sender: TObject);
- begin
- DragAcceptFiles(Handle, False);
- end;
-
- procedure TForm1.WMDropFiles(var Msg: TWMDropFiles);
- {$ifdef Windows}
- const
- MAX_PATH=255;
- {$endif}
- var
- Pt: TPoint;
- Count, Loop: Integer;
- Buf: array[0..MAX_PATH] of Char;
- begin
- try
- Msg.Result := 0;
- DragQueryPoint(Msg.Drop, Pt);
- Caption := Format('Files dropped at (%d,%d)',
- [Pt.X, Pt.Y]);
- Count := DragQueryFile(
- Msg.Drop, Cardinal(-1), Buf, SizeOf(Buf));
- for Loop := 0 to Pred(Count) do
- begin
- DragQueryFile(Msg.Drop, Loop, Buf, SizeOf(Buf));
- lstFiles.Items.Add(StrPas(Buf))
- end
- finally
- DragFinish(Msg.Drop)
- end
- end;
-
- end.
-